<template>
  <div class="home">
    <header-top />
    <div class="containerWid">
      <div class="main-banner">
        <div class="banner">
          <swiper
            :options="swiperOption"
            ref="mySwiper"
          >
            <!-- slides -->
            <swiper-slide>
              <img src="@/assets/img/test/test.jpg">
              <div class="slide-title">
                <p>Java架构师成长直通车</p>
              </div>
            </swiper-slide>
            <swiper-slide><img src="@/assets/img/test/test1.jpg">
              <div class="slide-title">
                <p>Java架构师成长直通车</p>
              </div>
            </swiper-slide>
            <swiper-slide><img src="@/assets/img/test/test.jpg">
              <div class="slide-title">
                <p>Java架构师成长直通车</p>
              </div>
            </swiper-slide>
            <!-- Optional controls -->
            <div
              class="swiper-pagination"
              slot="pagination"
            ></div>

        </swiper>
      </div>
      <div class="notice">
        <span class="noticeTit">公告</span>
        <ul class="noticeUl">
          <li
            v-for="index in 6"
            :key="index"
          >
            <span class="span">
              <router-link to="">公告中心</router-link>
            </span>
            <router-link
              class="link"
              to="/detail/1"
            >论坛资源下载常见问题汇总</router-link>
              <em class="author">ctokey</em>
              </li>
        </ul>
      </div>
    </div>
    <div class="main-container">
      <div class="classifyBox">
        <h3 class="classifyTit">编程开发</h3>
        <ul>
          <li
            v-for="index in 40"
            :key="index"
            @click="goCourse"
          >
            <img
              v-if="index % 2"
              src="@/assets/img/2.png"
            >
              <img
                v-else
                src="@/assets/img/3.png"
              >
                <div class="name">
                  <h3>{{index % 2 != 0 ? 'Web前端' : 'PHP'}}</h3>
                  <p>主题：26</p>
                </div>
                </li>
        </ul>
      </div>
      <right-modal />
    </div>
  </div>
  <bottom-footer />
  </div>
</template>

<script>
// @ is an alias to /src
import HeaderTop from '@/components/HeaderTop.vue'
import RightModal from '@/components/RightModal.vue'
import BottomFooter from '@/components/Footer.vue'
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'

export default {
  name: 'Home',
  components: {
    HeaderTop,
    RightModal,
    BottomFooter,
    swiper,
    swiperSlide
  },
  data() {
    return {
      swiperOption: {
        autoplay: true,
        pagination: {
          clickable: true,
          el: '.swiper-pagination'
        }
      }
    }
  },
  methods: {
    goCourse() {
      this.$router.push('/course')
    }
  }
}
</script>
<style lang="scss">
.home {
  background: url(../assets/img/bodybg.png) repeat;
}
.main-banner {
  background-color: #fff;
  padding: 15px;
  margin-top: 10px;
  border: 1px solid #e3e5e8;
  border-radius: 3px;
  height: 240px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  .banner {
    width: 550px;
    height: 240px;
    .swiper-slide {
      position: relative;
      height: 240px;
      img {
        width: 100%;
        height: 100%;
      }
      .slide-title {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 50px;
        line-height: 50px;
        text-align: left;
        padding: 0 20px;
        background: rgba(0, 0, 0, 0.3);
        font-size: 16px;
        color: #fff;
      }
    }
    .swiper-pagination {
      bottom: 16px;
      text-align: right;
      padding-right: 10px;
      box-sizing: border-box;
      .swiper-pagination-bullet {
        background: rgba(255, 255, 255, 0.75);
      }
      .swiper-pagination-bullet-active {
        background: rgba(255, 255, 255, 0.95);
        width: 20px;
        border-radius: 4px;
      }
    }
  }
  .notice {
    width: 550px;
    .noticeTit {
      display: inline-block;
      padding: 0 15px;
      cursor: pointer;
      font-size: 14px;
      height: 30px;
      line-height: 30px;
      color: #fff;
      background: #555;
      border-radius: 5px;
      margin-bottom: 10px;
    }
    .noticeUl {
      li {
        line-height: 28px;
        display: flex;
        position: relative;
        .span {
          display: inline-block;
          padding-right: 15px;
          margin-right: 15px;
          position: relative;
          &::after {
            content: '';
            width: 0;
            height: 14px;
            border-left: 1px solid #e5e5e5;
            position: absolute;
            right: 0;
            top: 8px;
          }
          a {
            font-size: 12px;
            color: #999;
          }
        }
        .link {
          line-height: 30px;
          color: #333;
          display: inline-block;
          max-width: 400px;
          @include textOverflow();
          @include textHover();
        }
        .author {
          position: absolute;
          right: 20px;
          font-size: 12px;
          color: #999;
          font-style: normal;
        }
      }
    }
  }
}
.main-container {
  margin-bottom: 10px;
  overflow: hidden;
  .classifyBox {
    float: left;
    background-color: #fff;
    width: 880px;
    .classifyTit {
      height: 54px;
      line-height: 54px;
      padding: 0 20px;
      border-bottom: 3px solid #f6f6f6;
    }
    ul {
      overflow: hidden;
      padding: 10px 0;
      li {
        box-sizing: border-box;
        padding: 15px 0;
        @include center();
        float: left;
        width: 250px;
        margin-right: 65px;
        img {
          width: 54px;
          margin-right: 10px;
          @include imgHover();
        }
        .name {
          width: 150px;
          h3 {
            font-size: 18px;
            line-height: 18px;
            font-weight: 400;
            cursor: pointer;
            @include textHover();
          }
          p {
            font-size: 12px;
            color: #666;
            margin-top: 6px;
          }
        }
        &:nth-child(3n) {
          margin-right: 0;
        }
      }
    }
  }
}
</style>
